
#ifndef SD_FILEMAN_H
#define SD_FILEMAN_H


#include "stdint.h"

// class struct
typedef struct{
	uint8_t 	fileTotalNum;
	uint32_t 	fileSize;
	
	uint8_t 	w_FileIndex;
	uint32_t 	w_FilePtr;
	
	uint8_t 	r_FileIndex;
	uint32_t 	r_FilePtr;
	
	uint8_t 	lastToRead;
	
	uint8_t 	data_FileName[16];
	
	uint8_t 	Info_FileName[16];
	
	uint8_t 	SdInfo_FileBuf[10];
	
	uint8_t 	loadSDInfo;
	
	uint32_t 	transSize;
}FILEMAN_STRUCT, *pFILEMAN_STRUCT;


//Function Protype
void 		FM_Init(FILEMAN_STRUCT *fm,uint8_t fileTN,uint32_t fileS,uint8_t fileNameID);
void 		FM_SetReadForm(FILEMAN_STRUCT *fm,uint8_t readTotal,uint32_t transS,uint32_t maxS);

uint8_t 	FM_ReadFile(FILEMAN_STRUCT *fm,uint8_t *buf, uint32_t *len,uint32_t toRead);
uint8_t 	FM_SaveDataToFile(FILEMAN_STRUCT *fm,uint8_t *buf, uint32_t len,uint32_t *bytesWritten);
uint8_t 	FM_readAllFileStatus(FILEMAN_STRUCT *fm,uint8_t *buf,uint32_t *len);
uint8_t 	FM_Delete(uint8_t *path);
uint8_t 	FM_CreateDir(uint8_t *path);
uint8_t 	FM_RenameFile(uint8_t *oldname,uint8_t* newname);
uint8_t 	FM_readDirItems(uint8_t *name,uint8_t *readbuf);
uint8_t 	FM_readFreeSectors(uint8_t *path,uint8_t *buf);




extern uint8_t GetSdFileStats(uint32_t *size,
							uint8_t* name);
extern uint8_t WriteSdFile(uint8_t *buf,
							uint32_t bytesOffset,
							uint32_t bytesToWrite,
							uint32_t *bytesWrite,
							uint8_t* name);
extern uint8_t FindSdFile(uint8_t *buf,
							uint32_t bytesOffset,
							uint32_t bytesToRead,
							uint32_t *bytesRead,
							uint8_t* name);						


#endif
//EOF





